/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
//import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author The Lunatics
 */
@Entity
@Table(name = "users")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Users.findAll", query = "SELECT u FROM Users u"),
    @NamedQuery(name = "Users.findByUserId", query = "SELECT u FROM Users u WHERE u.userId = :userId"),
    @NamedQuery(name = "Users.findByAccountCreationDate", query = "SELECT u FROM Users u WHERE u.accountCreationDate = :accountCreationDate"),
    @NamedQuery(name = "Users.findByRating", query = "SELECT u FROM Users u WHERE u.rating = :rating")})
public class Users implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    //@NotNull
    @Column(name = "User_Id")
    private Integer userId;
    @Basic(optional = false)
    //@NotNull
    @Column(name = "Account_Creation_Date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date accountCreationDate;
    @Column(name = "Rating")
    private Integer rating;
    @ManyToMany(mappedBy = "usersCollection")
    private Collection<Comments> commentsCollection;
    @ManyToMany(mappedBy = "usersCollection")
    private Collection<Circles> circlesCollection;
    @ManyToMany(mappedBy = "usersCollection")
    private Collection<Posts> postsCollection;
    @JoinColumn(name = "SSN", referencedColumnName = "SSN")
    @ManyToOne
    private Persons ssn;
    @OneToMany(mappedBy = "author")
    private Collection<Posts> postsCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userId")
    private Collection<Logins> loginsCollection;
    @OneToMany(mappedBy = "sender")
    private Collection<Messages> messagesCollection;
    @OneToMany(mappedBy = "receiver")
    private Collection<Messages> messagesCollection1;
    @OneToMany(mappedBy = "ownerOfCircle")
    private Collection<Circles> circlesCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "users")
    private Collection<UserPreferences> userPreferencesCollection;
    @OneToMany(mappedBy = "author")
    private Collection<Comments> commentsCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "users")
    private Collection<UserHasAccount> userHasAccountCollection;

    public Users() {
    }

    public Users(Integer userId) {
        this.userId = userId;
    }

    public Users(Integer userId, Date accountCreationDate) {
        this.userId = userId;
        this.accountCreationDate = accountCreationDate;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Date getAccountCreationDate() {
        return accountCreationDate;
    }

    public void setAccountCreationDate(Date accountCreationDate) {
        this.accountCreationDate = accountCreationDate;
    }

    public Integer getRating() {
        return rating;
    }

    public void setRating(Integer rating) {
        this.rating = rating;
    }

    @XmlTransient
    public Collection<Comments> getCommentsCollection() {
        return commentsCollection;
    }

    public void setCommentsCollection(Collection<Comments> commentsCollection) {
        this.commentsCollection = commentsCollection;
    }

    @XmlTransient
    public Collection<Circles> getCirclesCollection() {
        return circlesCollection;
    }

    public void setCirclesCollection(Collection<Circles> circlesCollection) {
        this.circlesCollection = circlesCollection;
    }

    @XmlTransient
    public Collection<Posts> getPostsCollection() {
        return postsCollection;
    }

    public void setPostsCollection(Collection<Posts> postsCollection) {
        this.postsCollection = postsCollection;
    }

    public Persons getSsn() {
        return ssn;
    }

    public void setSsn(Persons ssn) {
        this.ssn = ssn;
    }

    @XmlTransient
    public Collection<Posts> getPostsCollection1() {
        return postsCollection1;
    }

    public void setPostsCollection1(Collection<Posts> postsCollection1) {
        this.postsCollection1 = postsCollection1;
    }

    @XmlTransient
    public Collection<Logins> getLoginsCollection() {
        return loginsCollection;
    }

    public void setLoginsCollection(Collection<Logins> loginsCollection) {
        this.loginsCollection = loginsCollection;
    }

    @XmlTransient
    public Collection<Messages> getMessagesCollection() {
        return messagesCollection;
    }

    public void setMessagesCollection(Collection<Messages> messagesCollection) {
        this.messagesCollection = messagesCollection;
    }

    @XmlTransient
    public Collection<Messages> getMessagesCollection1() {
        return messagesCollection1;
    }

    public void setMessagesCollection1(Collection<Messages> messagesCollection1) {
        this.messagesCollection1 = messagesCollection1;
    }

    @XmlTransient
    public Collection<Circles> getCirclesCollection1() {
        return circlesCollection1;
    }

    public void setCirclesCollection1(Collection<Circles> circlesCollection1) {
        this.circlesCollection1 = circlesCollection1;
    }

    @XmlTransient
    public Collection<UserPreferences> getUserPreferencesCollection() {
        return userPreferencesCollection;
    }

    public void setUserPreferencesCollection(Collection<UserPreferences> userPreferencesCollection) {
        this.userPreferencesCollection = userPreferencesCollection;
    }

    @XmlTransient
    public Collection<Comments> getCommentsCollection1() {
        return commentsCollection1;
    }

    public void setCommentsCollection1(Collection<Comments> commentsCollection1) {
        this.commentsCollection1 = commentsCollection1;
    }

    @XmlTransient
    public Collection<UserHasAccount> getUserHasAccountCollection() {
        return userHasAccountCollection;
    }

    public void setUserHasAccountCollection(Collection<UserHasAccount> userHasAccountCollection) {
        this.userHasAccountCollection = userHasAccountCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userId != null ? userId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Users)) {
            return false;
        }
        Users other = (Users) object;
        if ((this.userId == null && other.userId != null) || (this.userId != null && !this.userId.equals(other.userId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Users[ userId=" + userId + " ]";
    }
    
}
